/**
 * 
 */
package com.gosophia.conferenceManagement.jbpm;

import org.apache.log4j.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.conferenceManagement.ConferenceConfiguration;

/**
 * 功能：
 * 
 * @author zhangdongsheng
 * @since 2011-3-23 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Service
@Transactional
public class ConferenceApplicationDecisionHandler implements DecisionHandler {
 
    private final Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private ConferenceConfiguration conferenceConfiguration;

    /*
     * (non-Javadoc)
     * 
     * @seeorg.jbpm.graph.node.DecisionHandler#decide(org.jbpm.graph.exe.
     * ExecutionContext)
     */
    @Override
    public String decide(ExecutionContext executionContext) throws Exception {
        String nodeName =  executionContext.getNode().getName();//节点名称
        String conferenceModel = executionContext
                .getVariable(conferenceConfiguration.CONFERENCE_MODEL) != null ? (String) executionContext
                .getVariable(conferenceConfiguration.CONFERENCE_MODEL)
                : "";// 会议发起模式，是否需要申请
         String distTransition="是";
           // 需要申请
        if (conferenceConfiguration.NEED_APPLICATION_CONFERENCE
                .equals(conferenceModel)) {
              distTransition="是";
        } else {
            distTransition= "否";
        }
        logger.debug("【"+ nodeName + "节点】取得发起模式conferenceModel：["+conferenceModel+"] 判定的 目标 transition：[" + distTransition+"]");
        return distTransition;
    }

}
